var tgd = tgd || {};
tgd.Simulations = tgd.Simulations || {};
tgd.Simulations.Zombies = tgd.Simulations.Zombies || {};

tgd.Simulations.Zombies.View = function (canvas) {

	var _divs = [];
	var _cnt = 0;

	if (tgd.Simulations.Zombies.View._initialized === undefined) {

		tgd.Simulations.Zombies.View.prototype.onRoundSimulated = function(opts) {

			var i = 0;

			while (_divs.length < opts.People.length) {
				var div = document.createElement("div");
				_divs.push(div);
				canvas.appendChild(div);
			}

			for (i = 0; i < opts.People.length; ++i) {
				var div = _divs[i];
				//todo: figure out the view stuff.  maybe events?
				switch (opts.People[i].Person.Type) {
					case tgd.Simulations.Zombies.Enums.HumanType.Civilian : div.className = "civ"; break;
					case tgd.Simulations.Zombies.Enums.HumanType.Hunter : div.className = "hun"; break;
					case tgd.Simulations.Zombies.Enums.HumanType.Zombie : div.className = "zom"; break;
					default : throw new Error("TODO");
				}
				if (opts.People[i].Person.State === tgd.Simulations.Zombies.Enums.LifeState.Dead) {
					if (div.className.indexOf("dead") < 0) {
						div.className += " dead"
					}
				}
				div.style.top = (opts.People[i].Location.Y - (opts.People[i].Person.Type === tgd.Simulations.Zombies.Enums.HumanType.Zombie ? 100 : 50)) + "px";
				div.style.left = (opts.People[i].Location.X - (opts.People[i].Person.Type === tgd.Simulations.Zombies.Enums.HumanType.Zombie ? 100 : 50)) + "px";
			}
		}

		tgd.Simulations.Zombies.View._initialized = true;
	}
}
